<template>
  <div class="con">
    <van-collapse v-model="activeNames">
      <van-collapse-item title="未完成" name="1">
        <ul>
          <li
            v-for="(item, index) in list"
            :key="index"
            v-show="item.status == 0"
          >
            <input type="checkbox" v-model="item.status" @change="changeItem" />
            <p>{{ item.title }}</p>
            <button @click="changeStatus({ index, status: 2 })">取消</button>
          </li>
        </ul>
      </van-collapse-item>
      <van-collapse-item title="已完成" name="2">
        <ul>
          <li
            v-for="(item, index) in list"
            :key="index"
            v-show="item.status == 1"
          >
            <input type="checkbox" v-model="item.status" @change="changeItem" />
            <p>{{ item.title }}</p>
            <span>{{ item.time }}</span>
          </li>
        </ul>
      </van-collapse-item>
      <van-collapse-item title="取消" name="3">
        <ul>
          <li
            v-for="(item, index) in list"
            :key="index"
            v-show="item.status == 2"
          >
            <input type="checkbox" />
            <p>{{ item.title }}</p>
            <button @click="changeStatus({ index, status: 0 })">还原</button>
          </li>
        </ul>
      </van-collapse-item>
    </van-collapse>
  </div>
</template>

<script>
import { mapMutations } from "vuex";
export default {
  data() {
    return {
      activeNames: ["1"],
    };
  },
  methods: {
    ...mapMutations(["changeItem", "changeStatus"]),
  },
  created() {},
  mounted() {},
  components: {},
  computed: {
    list() {
      return this.$store.state.list;
    },
  },
  watch: {},
};
</script>

<style lang="scss" scoped>
.con {
  h3 {
    display: flex;
    justify-content: space-between;
  }
  li {
    display: flex;
    justify-content: space-between;
  }
}
</style>
